<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <title>业主爱家</title>
    <link type="text/css" rel="stylesheet" href="css/common.css">
    <link type="text/css" rel="stylesheet" href="css/register.css">
    <script src="js/jquery-1.12.4.js"></script>
<script>
	  $(function(){
		  var flag=true;
		  $("#userName").blur(function(){
			  var userName=$(this).val();
			  if(userName=="" || userName ==null ){
				  $("#tips").text("用户名不为空"); 
				  flag=false;
			  }else{
				  $.get("checkuserName",{username:$(this).val()},function(data){
					  if(data>0){
						  $("#tips").text("用户名存在");
						  flag=false;
					  }else {
						  $("#tips").text("");
						  
					  }
				  })
			  }
		  })
		    $("#password").blur(function(){
		    var name=$(this).val();
		    	  var reg=/^[A-Za-z0-9]{6,18}$/
		    	  if(name=="" || name ==null){
					  $("#tipwd").text("该项是必填项！");
					  flag=false;
		    	  }else{
		    		  if(!reg.test(name)){
						  $("#tipwd").text("6-18位数字和字母组成");  
						  flag=false;
		    		  }else{
		    			  $("#tipwd").text("");
		   			  
		    		  }
		    	  }
		    })
		    $("#rpassword").blur(function(){
		    	  var $pwd = $("#rpassword").val();
		           var $divID = $("#password").val();
		             if($pwd=="" || $pwd ==null){
						  $("#tirpwd").text("该项是必填项！");
						  flag=false;
			    	  }else{
			    		  if ($pwd == $divID) {
			    			  $("#tirpwd").text("");  
			    			 
				           }else{
				        	   $("#tirpwd").text("密码不一致！");
				        	   flag=false;
				           } 
			    	  }
		    })
		     $("#email").blur(function () {
                   var ee=$(this).val();
                   if(ee=="" || ee ==null){
                       $("#tiemail").text("邮箱不能为空！");
                       flag=false;
                   }else{
                   if(0<ee.indexOf('@')+1<ee.indexOf('.')){
                       $("#tiemail").text("")
                      
                   }
                   else {
                       $("#tiemail").text("邮箱格式不对！");
                       flag=false;
                   }
                   }
               })
               
                $("#phone").blur(function () {
                   var phone=$(this).val();
                   var reg=/^\d{1,11}$/;
                	   if(phone=="" || phone ==null){
                		   $("#tiPhone").text(""); 
                        }else{
                   
                        	  if(!reg.test(phone)){
          						  $("#tiPhone").text("电话号码必须是数字"); 
          						flag=false;
          		    		  }else {
          		    			
          		    			$("#tiPhone").text(""); 
          		    		  }
                        }
               })
               $("#securityPhone").blur(function () {
                   var security=$(this).val();
                   var reg=/^\d{1,11}$/
                        if(phone=="" || phone ==null){
                        	$("#tiecurityPhone").text(""); 
                        }else{
                        	 if(!reg.test(security)){
                        		
        						  $("#tiecurityPhone").text("电话号码必须是数字"); 
        						  flag=false;
        		    		  }else{
        		    			  
        		    			 $("#tiecurityPhone").text("");
        		    		  }
                        }
               })
                  $("#districtName").blur(function () {
                        if(districtName=="" || districtName ==null){
     						  $("#tidistrictName").text("该项是必填项！");
     						 flag=false;
     		    		  }else{
     		    			
     		    			 $("#tidistrictName").text("");
     		    		  }
                      
               })
               
               $("#logbtn").click(function(){
            	   var province = $(".province").val();
            	
		           var city = $(".city").val(); 
		           var Rdistrict = $(".Rdistrict").val(); 
		           
      	         if (province=="" && city=="" && Rdistrict==""){
      	        	  flag=false;
      	        	  $("#tprovince").text("该项是必填项！");   
      	        	  
      	         }else{
      	        	var sum=province+city+Rdistrict;
      	        	$("#districtDetail").val(sum);
      	        	if(flag==true){
      	        	$(".form-horizontal").submit(); 
      	        	}
      	         }   
      	        });  
	  })
</script>
</head>
<body>
<div id="background">
    <img src="image/bgLogin2.jpg" width="100%" height="100%"/>
</div>
<div id="title">
    <h3>物业平台管理</h3>
    <h4>管理员注册REGISTER</h4>
</div>
<div id="register">
  <form class="form-horizontal" role="form" action="insertRed" method="post">
    <table id="base">
        <tr>
            <td class="font">用户名：</td>
            <td colspan="2"><input type="text" name="userName" id="userName" placeholder="请输入用户名"/></td>
            <td style="color:red;" id="tips"></td>
        </tr>
        <tr>
            <td class="font">密码：</td>
            <td colspan="2"><input type="text" name="password" id="password" placeholder="请输入6-18位数字和字母组成密码"/></td>
            <td style="color:red;" id="tipwd"></td>
        </tr>
        <tr>
            <td class="font">重复密码：</td>
            <td colspan="2"><input type="text" name="" id="rpassword"  placeholder="请确认密码"/></td>
            <td style="color:red;" id="tirpwd"></td>
        </tr>
        <tr>
            <td colspan="3"><select class="province" ><option value=""  >——省——</option><option value="广东省" >广东省</option></select>
            <select name="city" class="city"><option value="">——市——</option><option value="广州市">广州市</option></select>
            <select class="Rdistrict"><option value="">——区——</option><option value="天河区">天河区</option></select></td>
            <td style="color:red;" id="tprovince"></td>
            <td><input type="hidden" name="districtDetail" id="districtDetail" value=""/></td>
        </tr>
    </table>
    <table id="details">
        <tr>
            <td class="font">小区名：</td>
            <td colspan="2"><input type="text" name="districtName" id="districtName" placeholder="请输入小区名"/></td>
            <td style="color:red;" id="tidistrictName"></td>
        </tr>
        <tr>
            <td class="font">物管电话：</td>
            <td colspan="2"><input type="text" name="phone" id="phone" placeholder="请输入物管电话"/></td>
            <td style="color:red;" id="tiPhone"></td>
        </tr>
        <tr>
            <td class="font">安保电话：</td>
            <td colspan="2"><input type="text" name="securityPhone"  id="securityPhone" placeholder="请输入安保电话"/></td>
            <td style="color:red;" id="tiecurityPhone"></td>
        </tr>
        <tr>
            <td class="font">邮箱：</td>
            <td colspan="2"><input type="text" name="email"  id="email" placeholder="请输入email"/></td>
            <td style="color:red;" id="tiemail"></td>
        </tr>
        <tr>
            <td></td>
            <td colspan="2"><a href="login"><button type="button" style="background-color:RGB(203, 221, 243);width:105px;height:30px;">返回登录</button></a>
            <button type="button" style="background-color:RGB(203, 221, 243);width:105px;height:30px;" id="logbtn">提交</button></td>
        </tr>
    </table>
    </form>
</div>
</body>
</html>